package com.wgy.blog.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author:Iny
 * @Data：2021/11/8 20:28
 */
@Configuration
public class FileConfig implements WebMvcConfigurer {
    private String uploadPath = "H:/培训/JAVA/upload/";
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        addResourceHandler:拦截的请求
//        addResourceLocations:文件的真是路径
        registry.addResourceHandler("/upload/**").addResourceLocations("file:"+uploadPath);
        registry.addResourceHandler("/avatar/**","/img/**")
                .addResourceLocations("classpath:/static/avatar/","classpath:/static/img/");
    }
}
